<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>元旦活动</title>
    <script type="text/javascript" src="./js/tool.js"></script>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <link rel="stylesheet" href="./css/normalize.min.css">
    <link rel="stylesheet" href="./css/animate.min.css">
    <link rel="stylesheet" href="./css/loading.css">

    <link rel="stylesheet" href="./css/common.min.css">
    <link rel="stylesheet" href="./css/style.min.css">
</head>

<body class="animated ">
    <div class="loading">
        <div class="cube cube1"><img src="./images/heart.png" alt="" /></div>
        <div class="cube cube2"><img src="./images/heart.png" alt="" /></div>
        <div class="cube cube3"><img src="./images/heart.png" alt="" /></div>
        <div class="cube cube4"><img src="./images/heart.png" alt="" /></div>
        <div class="cube cube5"><img src="./images/heart.png" alt="" /></div>
        <div class="loading-info">
            <p>加载中...</p>
        </div>
    </div>

    <header>
        <a href="#" class="logo"></a>
        <a href="#" class="ruler_link f30 liliang">活动规则</a>
    </header>
    <article></article>
    <footer>
        <a href="javascript:void(0)" id="gotoGame"></a>
        <a href="javascript:void(0)" id="gotoPrize"></a>
    </footer>
    <div class=" follow  animated panel">
        <div class="ruler_contianer panel_contianer">
            <!-- <a href="#" id="followBtn"></a> -->
            <p class="t-c m-t-30 lemiao"><i class="my_heart"></i>啊哦，你还没有关注哦~</p>
            <p class="t-c lemiao">扫一扫下方二维码关注“四川联通”即可参与游戏</p>
            <p class="t-c"> <a href="javascript:void(0);" id="imgCode">
                <img src="./images/wechat.png" alt="">
                </a>
            </p>
        </div>
    </div>
    <div class="bindphone animated panel ">
        <div class="bindphone_contianer panel_contianer ">
            <a href="# " id="rulerBtn "></a>
            <p class="t-c f48 "><i class="my_heart_broken"></i></p>
            <p class="f30 ">啊哦，您还没有绑定手机号码， 无法领取流量哦~</p>
            <p class="t-c"> <a href="" id="bindBtn">
                        </a>
            </p>
        </div>
    </div>
    <div class="ruler animated panel">
        <div class=" follow_contianer panel_contianer">
            <a href="#" id="rulerBtn"></a>
            <p class="t-c f48 lianghei"><i class="my_heart"></i>活动规则</p>
            <p class="f30">1. 活动时间：2017年12月22日至2018年1月1日；
            </p>
            <p class="f30">2. 所有关注四川联通用户均可参加，每个用户只有一次参与机会，有一定概率获得奖品；</p>
            <p class="f30"> 3. 活动期间若取消绑定，可能会导致奖品赠送失败；</p>
            <p class="f30">4. 奖品领取办法请详见领取页面；</p>
            <p class="f30">5. 如未能在有效时间内使用E票网现金券或便携式保温杯兑换机会，则视为自动放弃奖品。</p>
        </div>
    </div>
    <script>
        //禁止拖动
        preventMove();
    </script>
    <script src='./js/follow.js'></script>
    <script type="text/javascript" src="./js/openInWeChat.js"></script>
    <script>
        //强制在微信浏览器打开
        WechatUseAgent();
    </script>
    <script>
        var opneid = 'o8QKAuJKAMHQZ26zxWmO1uAdwvgw';

        var ajaxNum = [1];

        lisetnerAjax(ajaxNum, 'body');

        function toGame() {
            location.href = './game.html?openid=' + opneid;
        }

        function failtoGame() {
            alert('您已经参加过游戏了');
        }

        function toPrize() {
            location.href = './prize.html?openid=' + opneid;
        }

        function failtoPrize() {
            alert('您还未参加过游戏了');
        }

        var app = {
            openId: opneid,
            init: function() {
                this.bindCheck();
                this.closePanel();
                this.rulerPanel();
                this.getUserRecord();

            },
            routerLink: function() {
                $('#gotoGame').on('click', toGame);
                $('#gotoPrize').on('click', toPrize);
            },

            closePanel: function() {
                $('#followBtn').click(function() {
                    $('.follow').addClass('slideOutUp').removeClass('slideInDown');
                });
                $('#rulerBtn').click(function() {
                    $('.ruler').addClass('slideOutUp').removeClass('slideInDown');
                })
            },
            rulerPanel: function() {
                $('.ruler_link').click(function(e) {
                    e.preventDefault();
                    $('.ruler').show().addClass('slideInDown').removeClass('slideOutUp');
                })
            },
            getUserRecord: function() {
                var context = this;
                context.routerLink();
                $.ajax({
                    tyle: 'post',
                    url: "http://10.122.202.211:8080/HD-newyear/newyear/getUserRecord.action",
                    dataType: "jsonp",
                    jsonp: "callback",
                    data: {
                        openid: context['openId']
                    },
                    beforeSend: function() {
                        //判断openId传过来了没有
                        if (!Boolean(app['openId'])) {
                            alert('获取openId失败');
                        }
                    },
                    success: function(reospnse) {

                        if (0 == reospnse.code) {
                            //显示文字
                            if (!Boolean(reospnse.data)) {
                                $('#gotoPrize').off('click');
                                $('#gotoPrize').on('click', failtoPrize);
                            } else {
                                $('#gotoGame').off('click');
                                $('#gotoGame').on('click', failtoGame);

                            }
                        }
                    },
                    error: function() {}
                });
            },
            bindCheck: function() {
                var context = this;
                context.user = judgeFocuse(app['openid']);
                var timer = setInterval(function() {
                    if (Boolean(context.user['name'])) {
                        $('#uImg').attr('src', context.user.imgUrl);
                        $('#uName').text(context.user.name);
                        clearInterval(timer);
                        timer = null;
                    }
                }, 200);

            }
        }
        app.init();
    </script>
</body>

</html>
